import request from '@/utils/request'

// 获取试卷列表
export function getPapers(params) {
    return request({
        url: '/exam-papers',
        method: 'get',
        params
    })
}

// 获取试卷详情
export function getPaper(id) {
    return request({
        url: `/exam-papers/${id}`,
        method: 'get'
    })
}

// 添加试卷
export function addPaper(data) {
    return request({
        url: '/exam-papers',
        method: 'post',
        data
    })
}

// 更新试卷
export function updatePaper(data) {
    return request({
        url: `/exam-papers/${data.id}`,
        method: 'put',
        data
    })
}

// 删除试卷
export function deletePaper(id) {
    return request({
        url: `/exam-papers/${id}`,
        method: 'delete'
    })
}

// 更新试卷状态
export function updateStatus(id, status) {
    return request({
        url: `/exam-papers/${id}/status`,
        method: 'put',
        data: { status }
    })
}

// 获取试卷题目
export function getPaperQuestions(id) {
    return request({
        url: `/exam-papers/${id}/questions`,
        method: 'get'
    })
}

// 获取考试记录
export function getRecords(params) {
    return request({
        url: '/exam-records',
        method: 'get',
        params
    })
}

// 获取考试记录详情
export function getRecordDetails(id) {
    return request({
        url: `/exam-records/${id}/details`,
        method: 'get'
    })
}

// 提交考试答案
export function submitExam(id, data) {
    return request({
        url: `/exam-records/submit`,
        method: 'post',
        data
    })
}

// 获取错题列表
export function getWrongQuestions(params) {
    return request({
        url: '/exam-records/wrong-questions',
        method: 'get',
        params
    })
}

// 根据错题生成练习
export function generateExercise(data) {
    return request({
        url: '/training-papers/wrong-questions',
        method: 'post',
        data
    })
}

// 根据规则生成试卷
export function generatePaper(data) {
    return request({
        url: '/exam-papers/generate',
        method: 'post',
        data
    })
}

// 获取考试统计数据
export function getExamStatistics() {
    return request({
        url: '/exam-records/statistics',
        method: 'get'
    })
}

// 获取个人成绩趋势
export function getScoreTrend(params) {
    return request({
        url: '/exam-records/score-trend',
        method: 'get',
        params
    })
}

// 获取班级成绩统计
export function getClassScoreStatistics(params) {
    return request({
        url: '/exam-records/class-statistics',
        method: 'get',
        params
    })
} 